/*
 * Created on 2005-9-1
 *
 * TODO To change the template for this generated file go to
 * Window - Preferences - Java - Code Style - Code Templates
 * TODO To change the template for this generated file go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
package com.store;

import com.jedi.BaseObj;
import com.jedi.KeyGen;
import com.tss.util.DbConn;
import com.tss.util.DbRs;

/**
 * @author Administrator
 *
 * TODO To change the template for this generated type comment go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
public class TaskDetail extends BaseObj {
	public TaskDetail() {}
	public TaskDetail(String id) {this.id = id;}
	
	public void insert() {
		clearErr();
		DbConn conn = new DbConn();
		try {
			String sql = "";
			setId(KeyGen.nextID(""));
			sql = "insert into taskdetail (" +
				" taskid,revpartno,serialno,contextfile," +
				" contextdesc,outpartno,outserialno" +
				" ) values ( " +
				" ?,?,?,?,?," +
				" ?,?)";
			conn.prepare(sql);
		
			conn.setInt(1,getTaskId());
			conn.setString(2,getRevPartNo());
			conn.setString(3,getSerialNo());
			conn.setString(4,getContextFile());
			conn.setString(5,getContextDesc());
			conn.setString(6,getOutPartNo());
			conn.setString(7,getOutSerialNo());
			conn.executeUpdate();
		}
		catch(Exception ex) {
			ex.printStackTrace();
			setErr(ex.getMessage());
		}
		finally {
			conn.close();
		}
	}
	
	public void update() {
		clearErr();
		DbConn conn = new DbConn();
		try {
			if (getId().trim().equals("")) {
				setErr("û��Ҫ���µļ�¼ID��");
				return;
			}
			String sql = "";
			sql = "update taskdetail set" +
				" taskid = ? ,revpartno = ? ,serialno = ? , contextfile = ? ," +
				" contextdesc = ? , outpartno = ? , outserialno = ? " +
				" where listid = ?";
			conn.prepare(sql);
			conn.setInt(1,getTaskId());
			conn.setString(2,getRevPartNo());
			conn.setString(3,getSerialNo());
			conn.setString(4,getContextFile());
			conn.setString(5,getContextDesc());
			conn.setString(6,getOutPartNo());
			conn.setString(7,getOutSerialNo());
			conn.setString(8,getId());
			conn.executeUpdate();
		}
		catch(Exception ex) {
			ex.printStackTrace();
			setErr(ex.getMessage());
		}
		finally {
			conn.close();
		}
	}
	
	public void delete() {
		clearErr();
		DbConn conn = new DbConn();
		DbRs rs = null;
		try {
			String sql = "";
			if (getPartid()==0) {
				setErr("没有要删除的信息");
				return;
			}
			sql = "delete from taskdetail where partid = ?";
			conn.prepare(sql);
			conn.setInt(1,getPartid());
			conn.executeUpdate();
		}
		catch(Exception ex) {
			ex.printStackTrace();
			setErr(ex.getMessage());
		}
		finally {
			conn.close();
		}
	}
	
	public String getId() {return id;}
	public int getTaskId() {return taskId;}
	public String getRevPartNo() {return revPartNo;}
	public String getOutPartNo() {return outPartNo;}
	public String getSerialNo() {return serialNo;}
	public String getOutSerialNo() {return outSerialNo;}
	public String getContextFile() {return contextFile;}
	public String getContextDesc() {return contextDesc;}

	protected void setId(String id) {this.id = id;}
	public void setTaskId(int taskId) {this.taskId = taskId;}
	public void setRevPartNo(String revPartNo) {this.revPartNo = revPartNo;}
	public void setOutPartNo(String outPartNo) {this.outPartNo = outPartNo;}
	public void setSerialNo(String serialNo) {this.serialNo = serialNo;}
	public void setOutSerialNo(String outSerialNo) {this.outSerialNo = outSerialNo;}
	public void setContextFile(String contextFile) {this.contextFile = contextFile;}
	public void setContextDesc(String contextDesc) {this.contextDesc = contextDesc;}

	private String id = "";
	private int partid=0;
	private int taskId = 0;
	private String revPartNo = "";
	private String outPartNo = "";
	private String serialNo = "";
	private String outSerialNo = "";
	private String contextFile = "";
	private String contextDesc = "";
	public int getPartid() {
		return partid;
	}
	public void setPartid(int partid) {
		this.partid = partid;
	}
}
